home *** CD-ROM | disk | FTP | other *** search
- X-ZC-POST: Amselweg 5; 45731 Waltrop
- X-ZC-TELEFON: +49-2309-920126
- X-Mailer: CrossPoint v3.11 R/C8604
- Message-ID: <66iHfO6PoYB@37.viking.ruhr.com>
- Organization: Ortwin Gasper
- X-Gateway: ZCONNECT UU viking.ruhr.com [DUUCP BETA vom 30.03.1996]
- References: <4kiai0$mjd@dfw-ixnews8.ix.netcom.com>
- From: gasper@viking.ruhr.com (Ortwin Gasper)
- Subject: Re: Why don't you use garbage collection
- Date: 12 Apr 1996 21:07:00 +0200
- Path: viking.ruhr.com!gasper
- Newsgroups: comp.lang.c++
- Distribution: world
-
- > So, do you use garbage collection in your C/C++ programs, and if not,
- > why not?
-
- Hi,
-
- I see the following problems:
- - If you want to program 'normally' (as you would do without the presence
- of a garbage collector), you can only choose a conservative one (see
- Boehm et alii). In this case
- - you must make assumptions on the compiler's behaviour.
- (if for (i=1;i<x;i++) a[i] = b[i] is internally transformed to machine
- code like (in C++-Syntax)
- someoffset = a - b;
- for (i=1;i<x;i++) b[i-someoffset] = b[i] // ***
- a = b + someoffset,
- garbage collection at the time of the loop, possibly caused by
- another thread, could reclaim a incorrectly)
- - you must accept, that the percentage of not reclaimed memory isn't
- bounded. (In Boehms collector an integer variable could hold for
- long times a value that (interpreted as a pointer) is a root to a
- very long chain of garbage.)
- In the real world these problems have no significance. But the problem
- of memory fragmentation remains.
- - If you want that a program never fails if the amount of needed memory m
- is <= C*n with n = the available memory and C a constant 0 < C <= 1, you
- must use copying collectors. But in this case, you can't program in
- 'normal' C++. You must remember the position of all pointers to the
- collected area, you must handle problems like 'what happens if the
- collector moves a class object while there is a stack frame from a
- member function of this object still valid'.
- ==> You can write C++-Programs using such a collector, but these
- programs won't look like C++, are hard to debug (and slow).
-
- The only portable solution I see is:
- Integrate garbage collection as an optional feature in the language and
- let the compiler do all the work for you. There could be a keyword like
- moveable, and rules like 'union { moveable * x; int y }' is not allowed.
- If this is done, everybody can work with well debugged collectors in a
- natural way. Programming becomes easier and more safe.
-
- Regards
-
- Ortwin
-
-
-
-
-
- ## CrossPoint v3.11 R ##
-